package hs.framework.opcClient.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import hs.framework.opcClient.entity.OPCServer;
import hs.framework.opcClient.utils.ServerInfo;
import org.jinterop.dcom.common.JIException;
import org.openscada.opc.lib.common.AlreadyConnectedException;
import org.openscada.opc.lib.common.NotConnectedException;
import org.openscada.opc.lib.da.AccessBase;
import org.openscada.opc.lib.da.DuplicateGroupException;
import org.openscada.opc.lib.da.Server;

import java.net.UnknownHostException;
import java.util.List;

public interface IOPCServerService extends IService<OPCServer> {


    /**
     * @Description 列出目标服务器上所有的opc服务器
     * @Return
     * @Author sxmz
     * @Date 2021/5/11 0011 下午 3:24
     */
    List<ServerInfo> getServers(OPCServer opcServer) throws Throwable;
    /**
     * @Description 连接到目标opc服务器
     * @Return
     * @Author sxmz
     * @Date 2021/5/11 0011 下午 3:26
     **/
    public Server openServer(OPCServer opcServer) throws AlreadyConnectedException, JIException, UnknownHostException;
    /**
     * @Description 获取opc服务器的连接状态
     * @Return
     * @Author sxmz
     * @Date 2021/5/11 0011 下午 3:45
     **/
    AccessBase getAccessBase(OPCServer opcServer) throws DuplicateGroupException, NotConnectedException, JIException, UnknownHostException, AlreadyConnectedException;

    /**
     * @Description 获取所有已连接的opc服务器
     * @Author sxmz
     * @Date 2021/5/14 0014 下午 4:06
     **/
    List<Server> getConnectServer();

    /**
     * @Description opc服务器断开连接
     * @Return
     * @Author sxmz
     * @Date 2021/5/11 0011 下午 3:55
     **/
    Boolean disposeServer(OPCServer opcServer);

    IPage<OPCServer> selectOPCServerPage(IPage<OPCServer> page, OPCServer opcServer);
}
